package com.goingup.simulation;

import java.util.Random;

public class Clock implements Runnable{

	private Random random;
	private Simulator simulator;
	@Override
	public void run() {
		while(true)
			randomlySleep();
	}
	private void randomlySleep() {
		long randomSleepTime = random.nextInt(6) * 1000;
		try {
			Thread.sleep(randomSleepTime);
			simulator.newArrival();
		} catch (InterruptedException e) {
			
		}
	}
	public Clock(Simulator simulator)
	{
		this.random = new Random();
		this.simulator = simulator;
		
	}
	
}
